﻿/***************************************************************
 * Name:      common.cpp
 * Purpose:   通用函数程序文件
 * Author:    杨卓荦 (yzl@bang5.net)
 * Created:   2010-08-29
 * Copyright: 杨卓荦 (http://www.bang5.net)
 * License:
 **************************************************************/
#include "common.h"

// trim space at head and rear
void Trim( std::string& str ) {
  std::string::size_type pos = str.find_last_not_of( ' ' );
  if ( pos != std::string::npos ) {
    str.erase( pos + 1 );
    pos = str.find_first_not_of( ' ' );
    if ( pos != std::string::npos )
      str.erase( 0, pos );
  } else
    str.erase( str.begin(), str.end() );
}
